<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Insert code using SyntaxHighlighter</title>
	<!--
	<script type="text/javascript" src="../../plugins/compat3x/tiny_mce_popup.js"></script>
	--><!--<script type="text/javascript" src="js/dialog.js"></script>
	--><style type="text/css" media="screen">
		input {
			vertical-align: middle;
		}
		label {
			vertical-align: middle;
		}
		fieldset {
			margin-bottom: 10px;
		}
		#insert{
			padding: 4px 10px;
			font-size: 14px;
			line-height: 20px;
			cursor: pointer;
			color: #333;
			text-align: center;
			overflow: visible;
			-webkit-appearance: none;
			min-width: 50px;
			color: #fff;
			text-shadow: 0 1px 1px rgba(255,255,255,.75);
			background-color: #006dcc;
			background-image: -moz-linear-gradient(top,#08c,#04c);
			background-image: -webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));
			background-image: -webkit-linear-gradient(top,#08c,#04c);
			background-image: -o-linear-gradient(top,#08c,#04c);
			background-image: linear-gradient(to bottom,#08c,#04c);
			background-repeat: repeat-x;
			filter: progid:DXImageTransform.Microsoft.gradient (startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
			zoom: 1;
			border-color: #04c #04c #002b80;
			border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
		}
	</style>
	<script type="text/javascript">
	function getWin() {
		return (!window.frameElement && window.dialogArguments) || opener || parent || top;
	}
	function close() {
		var t = this;
		var w = getWin();
		var tinymce = w.tinymce;
		// To avoid domain relaxing issue in Opera
		function close() {
			tinymce.EditorManager.activeEditor.windowManager.close(window);
			tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup
		};

		if (tinymce.isOpera)
			this.getWin().setTimeout(close, 0);
		else
			close();
	}
	
    
	function insertData() {
		var w = getWin();
		var tinymce = w.tinymce;
	    var f = document.forms[0], textarea_output, options = '', replace_element;

	    //If no code just return.
	    if(f.syntaxhl_code.value == '') {
	      close();
	      return false;
	    }

	    // get replacement argument to determine return type
	    replace_element = tinymce.activeEditor.getParam('replace_content');
	    var html = f.syntaxhl_code.value;
	    html = html.replace(/</g,"&lt;");
		html = html.replace(/>/g,"&gt;");
	    textarea_output = '<pre class="sourcecode language-'; /*Modify here based on the type of highlighter you are using*/
	    textarea_output += f.syntaxhl_language.value + '; ' + options + '">';
	    textarea_output += html;
	    textarea_output += '</pre>'; /* note space at the end, had a bug it was inserting twice? */

	    // check for replace_element option value and return output accordingly
	   if(replace_element == false) {
		    tinymce.execCommand('mceInsertContent', false, textarea_output);
	    } else {
	    	tinymce.execCommand('mceReplaceContent', false, textarea_output);
	    }
	    close();
	  }

	  
	</script>
</head>
<body>
<form action="#">
		<label for="syntaxhl_language">Choose Language:</label>
		<select name="syntaxhl_language" id="syntaxhl_language">
			<option value="applescript">AppleScript</option>
			<option value="as3">ActionScript3</option>
			<option value="bash">Bash</option>
			<option value="coldfusion">Cold Fusion</option>
			<option value="csharp">C#</option>
			<option value="cpp">C++</option>
			<option value="css">CSS</option>
			<option value="delphi">Delphi</option>
			<option value="diff">Diff</option>
			<option value="erlang">Erlang</option>
			<option value="groovy">Groovy</option>
			<option value="java">Java</option>
			<option value="javafx">JavaFX</option>
			<option value="jscript">Javascript</option>
			<option value="perl">Perl</option>
			<option value="php">PHP</option>
			<option value="powershell">PowerShell</option>
			<option value="python">Python</option>
			<option value="ruby">Ruby</option>
			<option value="sass">SASS</option>
			<option value="scala">Scala</option>
			<option value="sql">SQL</option>
			<option value="vb">VB</option>
			<option value="xml">XML/XHTML</option>
		</select>
	<br/><br/>
	<legend>Paste Code</legend>
	<textarea name="syntaxhl_code" id="syntaxhl_code" rows="15" cols="100" style="width: 100%; height:300px; font-family: 'Courier New',Courier,mono; font-size: 12px;" class="mceFocus"></textarea>
	<div class="mceActionPanel">
		<div style="float: left">
			<input type="button" id="insert" name="insert" value="Insert" onclick="javascript:insertData();"/>
		</div>
	</div>
</form>
</body>
</html>
